package net.models;

// Generated 11 avr. 2013 10:40:17 by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Fichefrais generated by hbm2java
 */
@Entity
@Table(name = "fichefrais", catalog = "bom")
public class Fichefrais extends AbstractModel {

	private Integer						id;
	private Users						users;
	private Etat					etat;
	private String						mois;
	private Integer						nbJustificatifs;
	private BigDecimal					montantValide;
	private Date						dateModif;
	private Set<Lignefraishorsforfait>	lignefraishorsforfaits	= new HashSet<Lignefraishorsforfait>(0);
	private Set<Lignefraisforfait>		lignefraisforfaits		= new HashSet<Lignefraisforfait>(0);

	public Fichefrais() {
	}

	public Fichefrais(Users users, String mois) {
		this.users = users;
		this.mois = mois;
	}

	public Fichefrais(Users users, Etat etat, String mois, Integer nbJustificatifs, BigDecimal montantValide, Date dateModif, Set<Lignefraishorsforfait> lignefraishorsforfaits, Set<Lignefraisforfait> lignefraisforfaits) {
		this.users = users;
		this.etat = etat;
		this.mois = mois;
		this.nbJustificatifs = nbJustificatifs;
		this.montantValide = montantValide;
		this.dateModif = dateModif;
		this.lignefraishorsforfaits = lignefraishorsforfaits;
		this.lignefraisforfaits = lignefraisforfaits;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		Integer oldValue = this.id;
		this.id = id;
		firePropertyChange("id", oldValue, id);
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", nullable = false)
	public Users getUsers() {
		return this.users;
	}

	public void setUsers(Users users) {
		Users oldValue = this.users;
		this.users = users;
		firePropertyChange("users", oldValue, users);
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idEtat")
	public Etat getEtat() {
		return this.etat;
	}

	public void setEtat(Etat etat) {
		Etat oldValue = this.etat;
		this.etat = etat;
		firePropertyChange("etat", oldValue, etat);
	}

	@Column(name = "mois", nullable = false, length = 6)
	public String getMois() {
		return this.mois;
	}

	public void setMois(String mois) {
		String oldValue = this.mois;
		this.mois = mois;
		firePropertyChange("mois", oldValue, mois);
	}

	@Column(name = "nbJustificatifs")
	public Integer getNbJustificatifs() {
		return this.nbJustificatifs;
	}

	public void setNbJustificatifs(Integer nbJustificatifs) {
		Integer oldValue = this.nbJustificatifs;
		this.nbJustificatifs = nbJustificatifs;
		firePropertyChange("nbJustificatifs", oldValue, nbJustificatifs);
	}

	@Column(name = "montantValide", precision = 10)
	public BigDecimal getMontantValide() {
		return this.montantValide;
	}

	public void setMontantValide(BigDecimal montantValide) {
		BigDecimal oldValue = this.montantValide;
		this.montantValide = montantValide;
		firePropertyChange("montantValide", oldValue, montantValide);
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "dateModif", length = 10)
	public Date getDateModif() {
		return this.dateModif;
	}

	public void setDateModif(Date dateModif) {
		Date oldValue = this.dateModif;
		this.dateModif = dateModif;
		firePropertyChange("dateModif", oldValue, dateModif);
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "fichefrais")
	public Set<Lignefraishorsforfait> getLignefraishorsforfaits() {
		return this.lignefraishorsforfaits;
	}

	public void setLignefraishorsforfaits(Set<Lignefraishorsforfait> lignefraishorsforfaits) {
		Set<Lignefraishorsforfait> oldValue = this.lignefraishorsforfaits;
		this.lignefraishorsforfaits = lignefraishorsforfaits;
		firePropertyChange("lignefraishorsforfaits", oldValue, lignefraishorsforfaits);
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "fichefrais")
	public Set<Lignefraisforfait> getLignefraisforfaits() {
		return this.lignefraisforfaits;
	}

	public void setLignefraisforfaits(Set<Lignefraisforfait> lignefraisforfaits) {
		Set<Lignefraisforfait> oldValue = this.lignefraisforfaits;
		this.lignefraisforfaits = lignefraisforfaits;
		firePropertyChange("lignefraisforfaits", oldValue, lignefraisforfaits);
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Fichefrais)
			return ((Fichefrais)obj).getId().equals(id);
		return super.equals(obj);
	}
}
